package fr.emse.tatiana.analysis.annotation;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import fr.emse.tatiana.corpus.Corpus;
import fr.emse.tatiana.display.BadDisplayFile;
import fr.emse.tatiana.replayable.analysis.AbstractAnalysisInput;
import fr.emse.tatiana.replayable.analysis.IAnalysis;

public class AnnotationAnalysisInput extends AbstractAnalysisInput {



	protected static int ID = 0;
	
	public AnnotationAnalysisInput(IProject project) {
		super(project);
		// TODO Auto-generated constructor stub
	}
	
	
	
	public AnnotationAnalysisInput(IFile file) {
		super(file);
	}



	public IAnalysis getModel() throws BadDisplayFile {
		if (model==null) {
			if (file == null) {
				model = new AnnotationAnalysis("UntitledAnalysis"+(ID++),p);
			} else {
				model = new AnnotationAnalysis(file);
			}
		}
		return model;
	}

	public boolean exists() {
		return file.exists();
	}

	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	public String getName() {
		try {
			return getModel().getName();
		} catch (BadDisplayFile e) {
			return "Untitled";
		}
	}

	public IPersistableElement getPersistable() {
		// TODO z later when persistence is implemented
		return null;
	}

	public String getToolTipText() {
		return getName();
	}

	public Object getAdapter(Class adapter) {
		return null;
	}
	
	public IFile getFile() {
		return this.file;
	}
	
	public void setFile(IFile file) {
		this.file=file;
	}

}
